---@class gift
local gift = {}
local this = gift
local import = import
local sign_unit = sign_unit



function gift.get_receive_activity_list()
    local list = sign_unit.event_list()
    local receive_list = {}
    for _, mainInfo in ipairs(list) do
        local sub_list = mainInfo.sub_list
        local name = mainInfo.name
        local sub_count = mainInfo.sub_count
        local main_id = mainInfo.id
        --if name == "钱包连接任务活动" then
        --    goto continue
        --end
        -- 将同一个目录下的子选项加入到一个表中
        local tmp_sub_list = {}
        if not table.is_empty(sub_list) then
            local finishSubNum = 0
            for k, subInfo in ipairs(sub_list) do
                local max_tar = subInfo.max_tar
                local cur_tar = subInfo.cur_tar
                local idx = subInfo.idx
                local sub_obj = subInfo.sub_obj

                if max_tar > 0 and sub_obj ~= 0 then
                    if cur_tar == max_tar then
                        local result = {
                            sub_id = main_id,
                            idx = idx - 1,
                        }
                        table.insert(tmp_sub_list, result)
                    end
                else
                    finishSubNum = finishSubNum + 1
                end
            end
            -- 领取最终奖励
            if finishSubNum == sub_count then
                table.insert(tmp_sub_list,
                    {
                        sub_id = main_id,
                        isFinal = true,
                    })
            end
            if not table.is_empty(tmp_sub_list) then
                table.insert(receive_list,
                    {
                        main_id = main_id,
                        name = name,
                        sub_list = tmp_sub_list,
                        reward_total_num = sub_count,
                    })
            end
        end
        ::continue::
    end
    return receive_list
end

return this
